Launching a pdf

Hi,

I want to open a pdf for users to view. Have used system call to do this, as
 

string szProgramName = "C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe"
 string szPdfName = "S:\\DXL_Development\\Help.pdf"
 string szCommand = szProgramName " " szPdfName ""
 system( szCommand )

 


The problem I'm facing is dynamically finding the path of the AcroRd32.exe, since users have this installed at different paths ( older versions of Acrobat or C:\\Programme\\... )

Is there an easy way to do this ?

Best regards, Paul

 


SystemAdmin - Wed Apr 27 03:49:07 EDT 2011

Re: Launching a pdf
Mathias Mamsch - Wed Apr 27 05:11:48 EDT 2011

You can use:
 

reg query "HKCU\Software\Adobe\Acrobat Reader" /s | findstr InstallPath

 


from the commandline to find the registry key with the installation path of adobe acrobat reader. From there you can read the "Standard" key... So in DXL you could do something like this:

 

 

 

string result = ""
win32SystemWait_ ("cmd.exe /C reg query \"HKCU\\Software\\Adobe\\Acrobat Reader\" /s | findstr InstallPath", result, -1)
// strip whitespaces at the end
int p = (length result)-1; while (isspace(result[p])) p--
 
print "Reading: '" result[0:p] "' \n"
print "Install Path: " getRegistry(result[0:p],"")



which prints for my installation:



 

 

 

 

Reading: 'HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\9.0\InstallPath' 
Install Path: C:\Programme\Adobe\Reader 9.0\Reader



Note that assumes the user has the REQ tool installed (which usually is installed with windows, however your IT might have disabled reading from the registry or removed the tool from the client PCs so if it does not work, you need to check the REG call from the commandline,to see if it works).

Hope that helps, regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Launching a pdf
Mathias Mamsch - Wed Apr 27 05:14:34 EDT 2011

by the way, you can probably start your PDF directly without calling acrobat reader provided you can double click on it, i.e. Acrobat Reader is associated with PDF. For this just run:
 

system("cmd /C start c:\\temp\\x.pdf")

 


which is probably the better solution.

Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Launching a pdf
SystemAdmin - Wed Apr 27 07:41:36 EDT 2011

Mathias Mamsch - Wed Apr 27 05:14:34 EDT 2011

by the way, you can probably start your PDF directly without calling acrobat reader provided you can double click on it, i.e. Acrobat Reader is associated with PDF. For this just run:
 

system("cmd /C start c:\\temp\\x.pdf")

 


which is probably the better solution.

Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Hi Mathias,

Thanks, that works fine

Best regards, Paul